package com.bwie.es.controller;

import com.alibaba.fastjson.JSONObject;
import com.bwie.common.domain.request.DocInfoReq;
import com.bwie.common.result.Result;
import com.bwie.es.service.EsDocService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Slf4j
@RequestMapping("/docEs")
public class EsDocController {
    @Autowired
    private EsDocService esDocService;

    @Autowired
    private HttpServletRequest request;

    /**
     * es文档的创建
     */
    @PostMapping("/createDoc")
    public Result createDoc(@RequestBody DocInfoReq DocInfoReq){
        log.info("功能名称:Es文档的创建,请求URI:{},请求方式:{},请求参数:{}",
                request.getRequestURI(),
                request.getMethod(),
                JSONObject.toJSONString(DocInfoReq));
        Result doc = esDocService.createDoc(DocInfoReq);
        log.info("功能名称:Es文档的创建,请求URI:{},请求方式:{},响应结果:{}",
                request.getRequestURI(),
                request.getMethod(),
                JSONObject.toJSONString(doc));
        return doc;
    }


}
